﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SHDM.Web.DataAccess
{
    public partial class sh_dept
    {
        static Dictionary<int, List<sh_dept>> _DeptParents = new Dictionary<int, List<sh_dept>>();

        public static List<sh_dept> GetParents(int deptID)
        {
            if (_DeptParents.ContainsKey(deptID))
            {
                return _DeptParents[deptID];
            }
            else
            {
                var lst = new SHDMEntities().Database.SqlQuery<sh_dept>($"call getDeptParent({deptID})").ToList();
                _DeptParents.Add(deptID, lst);
                return lst;
            }
        }

        public static void ClearParents()
        {
            _DeptParents.Clear();
        }
    }
}